package com.ruoyi.system.controller;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.VideoWarnEvent;
import com.ruoyi.system.service.IVideoWarnEventService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频分析-报警事件Controller
 * 
 * @author ruoyi
 * @date 2024-11-07
 */
@RestController
@RequestMapping("/system/videoWarnEvent")
public class VideoWarnEventController extends BaseController
{
    @Autowired
    private IVideoWarnEventService videoWarnEventService;

    /**
     * 查询视频分析-报警事件列表
     */
    @PreAuthorize("@ss.hasPermi('system:event:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoWarnEvent videoWarnEvent)
    {
        startPage();
        List<VideoWarnEvent> list = videoWarnEventService.selectVideoWarnEventList(videoWarnEvent);
        return getDataTable(list);
    }

    /**
     * 导出视频分析-报警事件列表
     */
    @PreAuthorize("@ss.hasPermi('system:event:export')")
    @Log(title = "视频分析-报警事件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoWarnEvent videoWarnEvent)
    {
        List<VideoWarnEvent> list = videoWarnEventService.selectVideoWarnEventList(videoWarnEvent);
        ExcelUtil<VideoWarnEvent> util = new ExcelUtil<VideoWarnEvent>(VideoWarnEvent.class);
        util.exportExcel(response, list, "视频分析-报警事件数据");
    }

    /**
     * 获取视频分析-报警事件详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:event:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(videoWarnEventService.selectVideoWarnEventById(id));
    }

    /**
     * 新增视频分析-报警事件
     */
    @PreAuthorize("@ss.hasPermi('system:event:add')")
    @Log(title = "视频分析-报警事件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoWarnEvent videoWarnEvent)
    {
        return toAjax(videoWarnEventService.insertVideoWarnEvent(videoWarnEvent));
    }

    /**
     * 修改视频分析-报警事件
     */
    @PreAuthorize("@ss.hasPermi('system:event:edit')")
    @Log(title = "视频分析-报警事件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoWarnEvent videoWarnEvent)
    {
        return toAjax(videoWarnEventService.updateVideoWarnEvent(videoWarnEvent));
    }

    /**
     * 删除视频分析-报警事件
     */
    @PreAuthorize("@ss.hasPermi('system:event:remove')")
    @Log(title = "视频分析-报警事件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(videoWarnEventService.deleteVideoWarnEventByIds(ids));
    }
}
